const express = require('express')
const app = express()
const port = 3000

//设置允许跨域访问该服务.
app.all('*', function (req, res, next) {
  res.header('Access-Control-Allow-Origin', '*');
  res.header('Access-Control-Allow-Headers', 'Content-Type');
  res.header('Access-Control-Allow-Methods', '*');
  res.header('Content-Type', 'application/json;charset=utf-8');
  next();
});

// 引入路由
var userRouter = require("./routes/user");
var gameRouter = require("./routes/game");
var menuRouter = require("./routes/menu");

// 路由挂载
app.use('/user', userRouter);
app.use('/menu', menuRouter);
app.use('/game', gameRouter);

app.listen(port, () => console.log(`服务器成功启动并监听在端口: ${port} 时间:   ${new Date().toLocaleString()}`))